import { SET_USERINFO } from "@/types/mutation-types";
window.console.log(SET_USERINFO);
const state = {
  name: "",
  age: "",
  nickname: "",
  ageInternet: "",
};
const mutations = {
  [SET_USERINFO]: function(state, payload) {
    const { name, age, nickname, ageInternet } = payload;
    //使用结构赋值简化代码
    state.name = name;
    state.age = age;
    state.nickname = nickname;
    state.ageInternet = ageInternet;
  },
};

const actions = {
  [SET_USERINFO]: function({ commit }, payload) {
    commit(SET_USERINFO, {
      //以载荷形式提交
      name: payload.name,
      age: payload.age,
      nickname: payload.nickname,
      ageInternet: payload.ageInternet,
    });
  },
};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
};